import Vue from 'vue'
import {
  Row,
  Col,
  Select,
  Option,
  Switch,
  Button,
  Loading,
  MessageBox,
  Message,
  Notification,
  Menu,
  Submenu,
  MenuItem,
  MenuItemGroup,
  RadioGroup,
  RadioButton,
} from 'element-ui'
const components = [
  Row,
  Col,
  Select,
  Option,
  Switch,
  Button,
  // Loading,
  // MessageBox,
  // Message,
  // Notification,
  Menu,
  Submenu,
  MenuItem,
  MenuItemGroup,
  RadioGroup,
  RadioButton,
]
// 组件注册
components.forEach(com=> {
  Vue.use(com)
})
// Vue.use(Row)
// Vue.use(Col)
// Vue.use(Button)
// Vue.use(Select)
// Vue.use(Option)
// Vue.use(Switch)
// 工具注入Vue.prototype
Object.assign(Vue.prototype, {
  $loading: Loading.service,
  $msgbox: MessageBox,
  $alert: MessageBox.alert,
  $confirm: MessageBox.confirm,
  $prompt: MessageBox.prompt,
  $notify: Notification,
  $message: Message,
})

// Vue.prototype.$loading = Loading.service;
// Vue.prototype.$msgbox = MessageBox;
// Vue.prototype.$alert = MessageBox.alert;
// Vue.prototype.$confirm = MessageBox.confirm;
// Vue.prototype.$prompt = MessageBox.prompt;
// Vue.prototype.$notify = Notification;
// Vue.prototype.$message = Message;

Vue.prototype.createLoading = function(){
  return this.$loading({
    lock: true,
    text: 'Loading',
    spinner: 'el-icon-loading',
    customClass: 'modal-loading',
    background: 'rgba(0, 0, 0, 0.3)',
    fullscreen: true,
  });
}

// 对message的公共配置统一处理
Vue.prototype.createMessage = (message, type, showClose=true,)=> {
  this.$message({
    message,
    type,
    showClose,
  })
}
